<template>
  <el-dialog
    width="40%"
    title="培训计划详情"
    :visible.sync="open"
    :before-close="close"
  >
    <el-descriptions title="基础信息" column="1">
      <el-descriptions-item label="计划名称">{{ info.planName }}</el-descriptions-item>
      <el-descriptions-item label="起始时间">{{ info.startTime }} 至 {{ info.endTime }}</el-descriptions-item>
      <el-descriptions-item label="状态">
        <dict-tag size="mini" style="margin-right: 5px" :options="dict.type.train_plan_status"
                  :value="info.status"/>
      </el-descriptions-item>
      <el-descriptions-item label="参与人">
        <el-tag size="mini" style="margin: 0 5px" v-for="(user, index) in info.users" :key="index">
          {{ user.nickName }}
        </el-tag>
      </el-descriptions-item>
    </el-descriptions>

    <el-descriptions title="培训信息" column="1" style="margin: 20px 0">
      <el-descriptions-item label="培训类型">
        <dict-tag size="mini" style="margin-right: 5px" :options="dict.type.train_plan_train_type"
                  :value="info.trainType"/>
      </el-descriptions-item>
      <el-descriptions-item v-if="info.trainType === '2'" label="负责人">{{ info.offlineTrainDirectorId }}
      </el-descriptions-item>
      <el-descriptions-item v-if="info.trainType === '2'" label="讲师">{{ info.offlineTrainLecturer }}
      </el-descriptions-item>
    </el-descriptions>

    <el-descriptions title="考试信息" column="1">
      <el-descriptions-item label="考试类型">
        <dict-tag size="mini" style="margin-right: 5px" :options="dict.type.train_plan_exam_type"
                  :value="info.examType"/>
      </el-descriptions-item>
      <el-descriptions-item v-if="info.examType === '1'" label="考题类型">{{ info.offlineExamDirectorId }}
      </el-descriptions-item>
      <el-descriptions-item v-if="info.examType === '1'" label="自选试卷">

      </el-descriptions-item>
      <el-descriptions-item v-if="info.examType === '2'" label="负责人">{{ info.offlineExamDirectorId }}
      </el-descriptions-item>
      <el-descriptions-item v-if="info.examType === '2'" label="考官">{{ info.offlineExamLecturer }}
      </el-descriptions-item>
    </el-descriptions>

  </el-dialog>
</template>

<script>
import {trainPlanInfo} from "@/api/edu/trainPlan";

export default {
  name: 'info',
  props: {
    open: {
      type: Boolean,
      default: false
    },
    close: {
      type: Function,
      default: () => {
      }
    },
    id: {
      type: String,
      default: ''
    }
  },
  dicts: ['train_plan_status', 'train_plan_train_type', 'train_plan_exam_type'],
  data() {
    return {
      loading: false,
      info: {}
    }
  },
  mounted() {
    this.getInfo()
  },
  methods: {
    getInfo() {
      trainPlanInfo(this.id).then(res => {
        this.info = res.data
      })
    }
  }
}
</script>

<style scoped>

</style>
